#include <algorithm>
#include <iostream>
using namespace std;

int main(void) {
  int n;
  int a[305];
  long long int total = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = 0;
  sort(a, a + n + 1);
  int l = 0, h = n, temp = 0;
  int *p = NULL;
  for (int i = 0; l != h; i++) {
    p = i % 2 ? &h : &l;
    total += (temp - a[*p]) * (temp - a[*p]);
    *p += i % 2 ? -1 : 1;
  }
  cout << total;
  return 0;
}